#ifndef DATE_OBJECT_H
#define DATE_OBJECT_H

#include <object_v2/object_v2.h>

typedef enum _DateObjectEvent DateObjectEvent;
enum _DateObjectEvent
{
        DATE_OBJECT_EVENT_DOT,
        DATE_OBJECT_EVENT_NUMBER,
        DATE_OBJECT_EVENT_ENDL,
        DATE_OBJECT_EVENT_OTHER
};

typedef enum _DateObjectState DateObjectState;
enum _DateObjectState
{
        DATE_OBJECT_STATE_START,
        DATE_OBJECT_STATE_RECV,
        DATE_OBJECT_STATE_REFRESH,
        DATE_OBJECT_STATE_FAILED,
        DATE_OBJECT_STATE_ENDL
};

OBJECT_DECLARE (DateObject, date_object)
#define DATE_OBJECT(any) ((DateObject*)(any))
struct _DateObject
{
        Object          parent_instance;
        DateObjectState date_state;
        int             year;
        int             month;
        int             day;
};

DateObject* date_object_new_with_today ();

/**
 * @brief DateObject 增加一天
 */
void date_object_add_days (DateObject* obj, int days);

/**
 * @brief 从日期字符串中分析出 DateObject，出错返回非0
 */
int date_object_analysis_date (DateObject* obj, ObjectStringApplication* str);

/**
 * @brief 根据开始日期和结束日期算出结束日期的周数
 */
int date_object_get_week_of_other_date (const DateObject* start_day,
                                        const DateObject* other_day);

/**
 * @brief 根据开始日期为星期一的 start_day 算出 end_day 是星期几
 */
int date_object_get_day_of_week (const DateObject* start_day,
                                 const DateObject* end_day);

/**
 * @brief 算出今天是第几周
 */
int date_object_get_week_of_today (const DateObject* start_day);

/**
 * @brief 根据开始日期和当前周数计算出该周星期一的 DateObject
 */
void date_object_get_monday_of_current_week (const DateObject* start_day,
                                             int               current_week,
                                             DateObject*       will_monday);

/**
 * @brief 比较日期是否相等。
 */
int date_object_compare (const DateObject* obj1, const DateObject* obj2);

#endif